<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:include="includeJs::bootstrap_js"></div>
    <div th:include="includeJs::layui_js"></div>
</head>
<body>
    <div class="container-scroller d-flex">
        <div th:replace="includeJs::admin_leftNav"></div>
        <div class="container-fluid page-body-wrapper">

            <div th:replace="includeJs::admin_nav"></div>
            <div class="page-header" align="center">
                <span><a th:href="@{/specimens/toSpecimensadd}">添加标</a></span>
            </div>

            <script type="text/html" id="toolbar">
                <!--批量删除-->
                <button type="button" lay-event="all" class="layui-btn layui-btn-normal layui-btn-sm" ><i class="layui-icon"></i>批量删除</button>
            </script>
            <script type="text/html" id="barDemo">
                <!--删除-->
                <button lay-event="del" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon"></i>删除</button>
                <!--编辑-->
                <button lay-event="edit" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon"></i>编辑</button>
            </script>
            <table class="layui-hide" lay-filter="test" id="demo"></table>
        </div>
    </div>
</body>
<script>
let layer;
let table;
layui.use(['table', 'layer'], function(){
    layer = layui.layer;
    table = layui.table;
        table.render({
            elem:'#demo',
            toolbar:'#toolbar',
            height:500,
            url:'/specimens/specimensList',
            title:'放标详情',
            cols:[
                [
                {type:'checkbox', fixed:'left'}
                ,{field:'sid',title:'放标编号', width:150, fixed: 'left', unresize: true, sort: true}
                ,{field:'name',title:'放标名称', width:170, sort: true}
                ,{field:'investhorizon', title:'投资期限(天)', width:150}
                ,{field:'expectedyield', title:'预期收益(%)', width:130}
                ,{field:'startmoney', title:'起投金额(元)',width:130}
                ,{field:'newStandard', title:'新手标(%)',width:130}
                ,{field:'plan', title:'进度',width:130}
                ,{field:'allmoney', title:'总金额', width:130}
                ,{field:'types', title:'类型', templet:function (d) {
                        if (d.types == 1) {
                            return '活期'
                        }else {
                            return '定期'
                        }
                    },width:130}
                ,{fixed: '', width:170, title:'操作', align:'center', toolbar: '#barDemo'}
            ]
            ],
            page: {limit:5,page:1,limits:[5,10,15],layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']}
        });

        //行工具栏
        table.on('tool(test)', function(obj){
            var datas = obj.data;//获取当前行数据
            var event = obj.event;//获得lay-event 对应的值（编辑，删除）
            if(event == 'edit'){
                window.location.href="/specimens/selectId/"+datas.sid
            }else if(event=='del'){
                window.location.href="/specimens/speDelete/"+datas.sid
            }
        });
    })
</script>
</html>